package com.example.roledepartment.controller;


import com.example.common.entity.Result;
import com.example.common.entity.sys.SysRole;
import com.example.roledepartment.service.ISysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 角色信息表 前端控制器
 * </p>
 *
 * @author cc
 * @since 2022-08-12
 */
@Api(tags = "角色信息管理")
@RestController
@RequestMapping("/sys-role")
public class SysRoleController {

    @Autowired
    private ISysRoleService roleService;

    @ApiOperation("通过用户id查询角色信息")
    @GetMapping("/roles/{userId}")
    public Result<List<SysRole>> getRolesByUserId(@PathVariable Long userId) {
       return Result.ok(roleService.getRolesByUserId(userId));
    }

}
